package AI;

import java.awt.Graphics;
import java.util.ArrayList;

import AI.Crew.*;
import AI.Enemy.Pirate;
import Items.Corpse;
import Main.SpaceGame;
import Tasks.Movement;

public class AiManager 
{
	public ArrayList<AiEntity> entityList = new ArrayList<AiEntity>();
	private SpaceGame main;
	
	public AiManager(SpaceGame main)
	{
		this.main = main;
		add(new Captain(40,30,main, 100));
	}
	
	public void add(AiEntity e)
	{
		entityList.add(e);
	}
	
	public void remove(AiEntity e)
	{
		entityList.remove(e);
	}
	
	public void kill(AiEntity e)
	{
		if(e instanceof Crew)
			main.itemManager.itemList.add(new Corpse(e.getX(), e.getY(), main, ((Crew) e).getName(), e.getClass().getSimpleName()));
		else
			main.itemManager.itemList.add(new Corpse(e.getX(), e.getY(), main, "", e.getClass().getSimpleName()));
		entityList.remove(e);
	}
	
	public void draw(Graphics g)
	{
		for(int i = 0;i<entityList.size();i++)
		{
			entityList.get(i).draw(g);
		}
	}
	
	public void update()
	{
		for(int i = 0;i<entityList.size();i++)
		{
			entityList.get(i).updateTask();
			entityList.get(i).step();
			entityList.get(i).update();
		}
	}
}
